using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace GSync
{
    public partial class ContactEditor : UserControl
    {
        private Hashtable difference;
        private int result = -1;

        public int Result
        {
            get { return result; }
            set { result = value; }
        }
        public Hashtable Difference
        {
            get { return difference; }
            set {
                difference = value;
                if (difference != null)
                {
                    initializeValue();
                }
            }
        }
        public ContactEditor()
        {
            InitializeComponent();
        }
        public ContactEditor(Hashtable difference)
        {
            this.difference = difference;
            InitializeComponent();
            initializeValue();
        }

        private void initializeValue()
        {
            String mesgOutlook = "";
            String mesgGoogle = "";
            if (this.difference == null)
            {
                return;
            }

            foreach (String key in difference.Keys)
            {
                if (!key.Equals(GManager.CONTACT_ITEM))
                {
                    mesgOutlook += key + " :" + ((Object[])difference[key])[GManager.OUTLOOK_ITEM] + "\r\n";
                    mesgGoogle += key + " :" + ((Object[])difference[key])[GManager.GOOGLE_ITEM] + "\r\n";
                }
            }
            this.outlookText.Text = mesgOutlook;
            this.googleText.Text = mesgGoogle;                 
        }


        private void skip_Click_1(object sender, EventArgs e)
        {
            this.Parent.Dispose();
        }

        private void contactEditApply_Click_1(object sender, EventArgs e)
        {
            if (googleRadio.Checked)
            {
                result = GManager.GOOGLE_ITEM;
               // Microsoft.WindowsMobile.PocketOutlook.Contact contact = (Microsoft.WindowsMobile.PocketOutlook.Contact)((Object[])difference[GManager.CONTACT_ITEM])[GManager.GOOGLE_ITEM];
               // contact.ShowDialog();
            }
            else if (outlookRadio.Checked)
            {
               // Microsoft.WindowsMobile.PocketOutlook.Contact contact = (Microsoft.WindowsMobile.PocketOutlook.Contact)((Object[])difference[GManager.CONTACT_ITEM])[GManager.GOOGLE_ITEM];
               // contact.ShowDialog();
                result = GManager.OUTLOOK_ITEM;
            }
            difference.Add("RESULT", result);
        }
    }
}
